#include <QCoreApplication>
#include <QTextStream>
#include <QTime>
#include <QDebug>

#include "core/CGlobal.h"
#include "core/CVM.h"
#include "core/COperationCodes.h"
#include "core/functions/CIO.h"
#include "core/CVMDataTypes.h"
#include "core/CCompiler.h"
#include "utils/CException.h"
#include "utils/CByteArray.h"

int main(int argc, char *argv[])
{
    try
    {
        if (argc != 2)
        {
            CGlobal::output << "wrong number of args!";
            return -1;
        }

        CByteArray btAr = CCompiler(argv[1]).compile();
        CVM vm(btAr.data(), btAr.size());
        vm.start();
        return 0;

    } catch(CException& e)
    {
        CGlobal::output << e.message() << endl << endl;
        return -1;
    } catch(exception& e)
    {
        CGlobal::output << "System exception: " << e.what() << endl << endl;
        return -1;
    }
}
